package com.sanchunhui.psc.service.impl

import com.sanchunhui.psc.data.protocol.ResponseInfo
import com.sanchunhui.psc.data.respository.UserRepository
import com.sanchunhui.psc.ext.convert
import com.sanchunhui.psc.ext.convertBoolean
import com.sanchunhui.psc.service.UserService
import rx.Observable
import javax.inject.Inject

/*
    用户模块业务实现类
 */
class UserServiceImpl @Inject constructor(): UserService {
    @Inject
    lateinit var repository: UserRepository

    /*
        注册
     */
    override fun register(mobile: String, pwd: String, verifyCode: String): Observable<Boolean> {
        return repository.register(mobile, pwd, verifyCode).convertBoolean()
    }

    /*
        登录
     */
    override fun login(mobile: String, pwd: String): Observable<ResponseInfo> {
        return repository.login(mobile, pwd)
    }

    /*
        注销登录
     */
    override fun logout(token: String): Observable<Boolean> {
        return repository.logout(token).convertBoolean()
    }

    /*
            忘记密码
         */
    override fun forgetPwd(mobile: String, verifyCode: String): Observable<Boolean> {
        return repository.forgetPwd(mobile, verifyCode).convertBoolean()
    }

    /*
        重置密码
     */
    override fun resetPwd(
        token: String,
        old_password: String,
        new_password: String
    ): Observable<ResponseInfo> {
        return repository.resetPwd(token,old_password,new_password)
    }

    /*
        修改用户资料
     */
    override fun editUser(userIcon: String, userName: String, userGender: String): Observable<ResponseInfo> {
        return repository.editUser(userIcon,userName,userGender)
    }

}
